//
//  AXFSearchViewController.m
//  AIXF
//
//  Created by Macx on 2017/7/10.
//  Copyright © 2017年 Macx. All rights reserved.
//

#import "AXFSearchViewController.h"
#import "AXFSearchKeyWordView.h"
#import "AXFClickKeyWordViewController.h"
#import <Masonry/Masonry.h>
@interface AXFSearchViewController ()

@property (nonatomic,strong)UITextField *searchBar;

@end

@implementation AXFSearchViewController

- (void)viewDidLoad {
    [super viewDidLoad];
   
    
    self.navigationController.navigationBar.translucent = NO;

    self.searchBar = (UITextField *)[UISearchBar new];
    
    self.navigationItem.titleView = self.searchBar;
    
    AXFSearchKeyWordView *view = [[AXFSearchKeyWordView alloc] init];
    
    [self.view addSubview:view];
    
    [view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.bottom.equalTo(self.view);
        
    }];
    
    for (UIView *subView in view.subviews)
    {
        
        if ([subView isKindOfClass:[UIButton class]])
        {
            UIButton *but = (UIButton *)subView;
            
            [but addTarget:self action:@selector(clickBtn:) forControlEvents:UIControlEventTouchUpInside];
        }
    }
    
}

- (void)clickBtn:(UIButton *)btn
{

    self.searchBar.text = btn.titleLabel.text;

    AXFClickKeyWordViewController *vc = [AXFClickKeyWordViewController new];
    
    [self.navigationController pushViewController:vc animated:YES];

}



@end
